{% extends "zinnia/base.html" %}
{% load i18n zinnia_tags %}
{% load url from future %}

{% block meta-description %}{% trans "Latest entries for" %} {% if category %}{% trans "the category" %} {{ category }}{% if category.description %}: {{ category.description|striptags|safe }}{% endif %}{% endif %}{% if tag %}{% trans "the tag" %} {{ tag }}{% endif %}{% if author %}{% trans "the author" %} {{ author }}{% endif %}{% if page_obj %}{% ifnotequal page_obj.number 1 %} {% trans "page" %} {{ page_obj.number }}{% endifnotequal %}{% endif %}{% endblock %}

{% block link %}
  {{ block.super }}
  {% if category %}
    <link rel="alternate" type="application/rss+xml" title="{% trans "RSS Feed" %} {{ category }}" href="{% url 'zinnia_category_feed' category.tree_path %}" />
  {% endif %}
  {% if tag %}
    <link rel="alternate" type="application/rss+xml" title="{% trans "RSS Feed" %} {{ tag }}" href="{% url 'zinnia_tag_feed' tag.name %}" />
  {% endif %}
  {% if author %}
    <link rel="alternate" type="application/rss+xml" title="{% trans "RSS Feed" %} {{ author }}" href="{% url 'zinnia_author_feed' author.username %}" />
  {% endif %}
{% endblock %}

{% block title %}{% trans "Latest entries" %} {% if category %}| {% trans "Category" %} {{ category }}{% endif %}{% if tag %}| {% trans "Tag" %} {{ tag }}{% endif %}{% if author %}| {% trans "Author" %} {{ author }}{% endif %}{% if page_obj %}{% ifnotequal page_obj.number 1 %} | {% trans "Page" %} {{ page_obj.number }}{% endifnotequal %}{% endif %}{% endblock %}

{% block body-class %}entry-list {% if category %}category category-{{ category.slug }}{% endif %}{% if tag %}tag tag-{{ tag|slugify }}{% endif %}{% if author %}author author-{{ author|slugify }}{% endif %}{% if page_obj %} paginated page-{{ page_obj.number }}{% endif %}{% endblock %}

{% block content %}

{% block content-title %}
{% if category %}
<h1>{% blocktrans %}Category archives: {{ category }}{% endblocktrans %}</h1>
{% if category.description %}
<p>{{ category.description|striptags|safe }}</p>
{% endif %}
{% endif %}

{% if tag %}
<h1>{% blocktrans %}Tag archives: {{ tag }}{% endblocktrans %}</h1>
{% endif %}

{% if author %}
<h1>{% blocktrans %}Author archives: {{ author }}{% endblocktrans %}</h1>
{% endif %}
{% endblock %}

{% block content-loop %}
{% for object in object_list %}
  {% with object_content=object.html_content|truncatewords_html:100|safe continue_reading=1 %}
  {% include "zinnia/_entry_detail.html" %}
  {% endwith %}
{% empty %}
  <p class="notice">
    <a href="{% url 'admin:zinnia_entry_add' %}">{% trans "No entries yet." %}</a>
  </p>
{% endfor %}
{% endblock %}

{% block content-pagination %}
{% if is_paginated %}
  {% zinnia_pagination page_obj %}
{% endif %}
{% endblock %}

{% block content-related %}
{% endblock %}

{% endblock %}

{% block admin_tools %}
  {% if category and perms.zinnia.change_category %}
  <li>
    <a href="{% url 'admin:zinnia_category_change' category.pk %}" title="{% trans "Edit the category" %}">
      {% trans "Edit the category" %}
    </a>
  </li>
  {% endif %}
  {% if tag and perms.tagging.change_tag %}
  <li>
    <a href="{% url 'admin:tagging_tag_change' tag.pk %}" title="{% trans "Edit the tag" %}">
      {% trans "Edit the tag" %}
    </a>
  </li>
  {% endif %}
  {% if author and perms.auth.change_user %}
  <li>
    <a href="{% url 'admin:auth_user_change' author.pk %}" title="{% trans "Edit the author" %}">
      {% trans "Edit the author" %}
    </a>
  </li>
  {% endif %}
{% endblock %}
